# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgname=featherduster
pkgver=191.9229158
pkgrel=3
pkgdesc='An automated, modular cryptanalysis tool.'
groups=('blackarch' 'blackarch-crypto')
arch=('any')
url='https://github.com/nccgroup/featherduster'
license=('custom:unknown')
depends=('python2' 'python2-gmpy' 'python2-pycryptodome' 'python2-ishell'
         'python2-requests' 'python2-singlefile' 'readline' 'ncurses')
makedepends=('git' 'python2-setuptools')
source=("git+https://github.com/nccgroup/$pkgname.git")
sha512sums=('SKIP')

pkgver() {
  cd $pkgname

  echo $(git rev-list --count HEAD).$(git rev-parse --short HEAD)
}

build() {
  cd $pkgname

  python2 setup.py build
}

package() {
  cd $pkgname

  install -dm 755 "$pkgdir/usr/bin"
  install -dm 755 "$pkgdir/usr/share/$pkgname"

  python2 setup.py install --root="$pkgdir" --optimize=1 --skip-build

  install -Dm 644 -t "$pkgdir/usr/share/doc/$pkgname" README.md INSTALL.md \
    CONTRIBUTING.md

  find "$pkgdir" -type f -iname '*.pyc' -exec rm {} + -or -iname '*.pyo' -exec rm {} \;

  rm *.md

  cp -a * "$pkgdir/usr/share/$pkgname/"

  cat > "$pkgdir/usr/bin/$pkgname" << EOF
#!/bin/sh
cd /usr/share/$pkgname
exec python2 $pkgname/$pkgname.py "\$@"
EOF

  chmod +x "$pkgdir/usr/bin/$pkgname"
}

